
from fastapi import FastAPI, Depends, Body
import yaml
import uvicorn
from service.FileVo import FileVo
from service.ResObj import ResObj
from service.ocrService import ocrService
with open('../config.yaml', 'r') as f:
    config = yaml.safe_load(f)
app = FastAPI()

def getOcrService():
    return ocrService()


@app.post("/ocr")
def ocr(es: ocrService =
        Depends(getOcrService),
        fileVo: FileVo = Body(None)):
    result = es.ocr_identify(fileVo.file_url)
    return ResObj(200, "操作成功", result, True)


if __name__ == '__main__':
    uvicorn.run(
        "ocrMain:app",  # 替换"模块名"为你的Python文件名(不带.py)
        host="127.0.0.1",
        port=8001,
        reload=True,  # 启用热部署
    )